2020-2021 Sunseeker Telemetry and Lighting System
usci_b_i2c.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // usci_b_i2c.h - Driver for the USCI_B_I2C Module.
4 //
5 //*****************************************************************************
6 
7 #ifndef __MSP430WARE_USCI_B_I2C_H__
8 #define __MSP430WARE_USCI_B_I2C_H__
9 
10 #include "inc/hw_memmap.h"
11 
12 #ifdef __MSP430_HAS_USCI_Bx__
13 
14 //*****************************************************************************
15 //
16 // If building with a C++ compiler, make all of the definitions in this header
17 // have a C binding.
18 //
19 //*****************************************************************************
20 #ifdef __cplusplus
21 extern "C"
22 {
23 #endif
24 
25 #include "inc/hw_memmap.h"
26 //*****************************************************************************
27 //
29 //
30 //*****************************************************************************
31 typedef struct USCI_B_I2C_initMasterParam {
36  uint8_t selectClockSource;
38  uint32_t i2cClk;
43  uint32_t dataRate;
44 } USCI_B_I2C_initMasterParam;
45 
46 
47 //*****************************************************************************
48 //
49 // The following are values that can be passed to the param parameter for
50 // functions: USCI_B_I2C_initMaster().
51 //
52 //*****************************************************************************
53 #define USCI_B_I2C_CLOCKSOURCE_ACLK UCSSEL__ACLK
54 #define USCI_B_I2C_CLOCKSOURCE_SMCLK UCSSEL__SMCLK
55 
56 //*****************************************************************************
57 //
58 // The following are values that can be passed to the param parameter for
59 // functions: USCI_B_I2C_initMaster().
60 //
61 //*****************************************************************************
62 #define USCI_B_I2C_SET_DATA_RATE_400KBPS 400000
63 #define USCI_B_I2C_SET_DATA_RATE_100KBPS 100000
64 
65 //*****************************************************************************
66 //
67 // The following are values that can be passed to the mode parameter for
68 // functions: USCI_B_I2C_setMode().
69 //
70 //*****************************************************************************
71 #define USCI_B_I2C_TRANSMIT_MODE UCTR
72 #define USCI_B_I2C_RECEIVE_MODE 0x00
73 
74 //*****************************************************************************
75 //
76 // The following are values that can be passed to the mask parameter for
77 // functions: USCI_B_I2C_enableInterrupt(), USCI_B_I2C_disableInterrupt(),
78 // USCI_B_I2C_clearInterrupt(), and USCI_B_I2C_getInterruptStatus() as well as
79 // returned by the USCI_B_I2C_getInterruptStatus() function.
80 //
81 //*****************************************************************************
82 #define USCI_B_I2C_STOP_INTERRUPT UCSTPIE
83 #define USCI_B_I2C_START_INTERRUPT UCSTTIE
84 #define USCI_B_I2C_RECEIVE_INTERRUPT UCRXIE
85 #define USCI_B_I2C_TRANSMIT_INTERRUPT UCTXIE
86 #define USCI_B_I2C_NAK_INTERRUPT UCNACKIE
87 #define USCI_B_I2C_ARBITRATIONLOST_INTERRUPT UCALIE
88 
89 //*****************************************************************************
90 //
91 // The following are values that can be passed toThe following are values that
92 // can be returned by the USCI_B_I2C_isBusy() function and the
93 // USCI_B_I2C_isBusBusy() function.
94 //
95 //*****************************************************************************
96 #define USCI_B_I2C_BUS_BUSY UCBBUSY
97 #define USCI_B_I2C_BUS_NOT_BUSY 0x00
98 
99 //*****************************************************************************
100 //
101 // The following are values that can be passed toThe following are values that
102 // can be returned by the USCI_B_I2C_masterIsStartSent() function.
103 //
104 //*****************************************************************************
105 #define USCI_B_I2C_SENDING_START UCTXSTT
106 #define USCI_B_I2C_START_SEND_COMPLETE 0x00
107 
108 //*****************************************************************************
109 //
110 // The following are values that can be passed toThe following are values that
111 // can be returned by the USCI_B_I2C_masterIsStopSent() function.
112 //
113 //*****************************************************************************
114 #define USCI_B_I2C_SENDING_STOP UCTXSTP
115 #define USCI_B_I2C_STOP_SEND_COMPLETE 0x00
116 
117 //*****************************************************************************
118 //
119 // Prototypes for the APIs.
120 //
121 //*****************************************************************************
122 
123 //*****************************************************************************
124 //
143 //
144 //*****************************************************************************
145 extern void USCI_B_I2C_initMaster(uint16_t baseAddress,
146  USCI_B_I2C_initMasterParam *param);
147 
148 //*****************************************************************************
149 //
164 //
165 //*****************************************************************************
166 extern void USCI_B_I2C_initSlave(uint16_t baseAddress,
167  uint8_t slaveAddress);
168 
169 //*****************************************************************************
170 //
180 //
181 //*****************************************************************************
182 extern void USCI_B_I2C_enable(uint16_t baseAddress);
183 
184 //*****************************************************************************
185 //
195 //
196 //*****************************************************************************
197 extern void USCI_B_I2C_disable(uint16_t baseAddress);
198 
199 //*****************************************************************************
200 //
213 //
214 //*****************************************************************************
215 extern void USCI_B_I2C_setSlaveAddress(uint16_t baseAddress,
216  uint8_t slaveAddress);
217 
218 //*****************************************************************************
219 //
233 //
234 //*****************************************************************************
235 extern void USCI_B_I2C_setMode(uint16_t baseAddress,
236  uint8_t mode);
237 
238 //*****************************************************************************
239 //
251 //
252 //*****************************************************************************
253 extern void USCI_B_I2C_slavePutData(uint16_t baseAddress,
254  uint8_t transmitData);
255 
256 //*****************************************************************************
257 //
266 //
267 //*****************************************************************************
268 extern uint8_t USCI_B_I2C_slaveGetData(uint16_t baseAddress);
269 
270 //*****************************************************************************
271 //
286 //
287 //*****************************************************************************
288 extern uint8_t USCI_B_I2C_isBusBusy(uint16_t baseAddress);
289 
290 //*****************************************************************************
291 //
307 //
308 //*****************************************************************************
309 extern uint8_t USCI_B_I2C_isBusy(uint16_t baseAddress);
310 
311 //*****************************************************************************
312 //
325 //
326 //*****************************************************************************
327 extern uint8_t USCI_B_I2C_masterIsStopSent(uint16_t baseAddress);
328 
329 //*****************************************************************************
330 //
343 //
344 //*****************************************************************************
345 extern uint8_t USCI_B_I2C_masterIsStartSent(uint16_t baseAddress);
346 
347 //*****************************************************************************
348 //
356 //
357 //*****************************************************************************
358 extern void USCI_B_I2C_masterSendStart(uint16_t baseAddress);
359 
360 //*****************************************************************************
361 //
382 //
383 //*****************************************************************************
384 extern void USCI_B_I2C_enableInterrupt(uint16_t baseAddress,
385  uint8_t mask);
386 
387 //*****************************************************************************
388 //
409 //
410 //*****************************************************************************
411 extern void USCI_B_I2C_disableInterrupt(uint16_t baseAddress,
412  uint8_t mask);
413 
414 //*****************************************************************************
415 //
436 //
437 //*****************************************************************************
438 extern void USCI_B_I2C_clearInterrupt(uint16_t baseAddress,
439  uint8_t mask);
440 
441 //*****************************************************************************
442 //
469 //
470 //*****************************************************************************
471 extern uint8_t USCI_B_I2C_getInterruptStatus(uint16_t baseAddress,
472  uint8_t mask);
473 
474 //*****************************************************************************
475 //
489 //
490 //*****************************************************************************
491 extern void USCI_B_I2C_masterSendSingleByte(uint16_t baseAddress,
492  uint8_t txData);
493 
494 //*****************************************************************************
495 //
510 //
511 //*****************************************************************************
512 extern bool USCI_B_I2C_masterSendSingleByteWithTimeout(uint16_t baseAddress,
513  uint8_t txData,
514  uint32_t timeout);
515 
516 //*****************************************************************************
517 //
531 //
532 //*****************************************************************************
533 extern void USCI_B_I2C_masterSendMultiByteStart(uint16_t baseAddress,
534  uint8_t txData);
535 
536 //*****************************************************************************
537 //
549 //
550 //*****************************************************************************
551 extern bool USCI_B_I2C_masterSendMultiByteStartWithTimeout(uint16_t baseAddress,
552  uint8_t txData,
553  uint32_t timeout);
554 
555 //*****************************************************************************
556 //
569 //
570 //*****************************************************************************
571 extern void USCI_B_I2C_masterSendMultiByteNext(uint16_t baseAddress,
572  uint8_t txData);
573 
574 //*****************************************************************************
575 //
589 //
590 //*****************************************************************************
591 extern bool USCI_B_I2C_masterSendMultiByteNextWithTimeout(uint16_t baseAddress,
592  uint8_t txData,
593  uint32_t timeout);
594 
595 //*****************************************************************************
596 //
610 //
611 //*****************************************************************************
612 extern void USCI_B_I2C_masterSendMultiByteFinish(uint16_t baseAddress,
613  uint8_t txData);
614 
615 //*****************************************************************************
616 //
631 //
632 //*****************************************************************************
633 extern bool USCI_B_I2C_masterSendMultiByteFinishWithTimeout(uint16_t baseAddress,
634  uint8_t txData,
635  uint32_t timeout);
636 
637 //*****************************************************************************
638 //
651 //
652 //*****************************************************************************
653 extern void USCI_B_I2C_masterSendMultiByteStop(uint16_t baseAddress);
654 
655 //*****************************************************************************
656 //
670 //
671 //*****************************************************************************
672 extern bool USCI_B_I2C_masterSendMultiByteStopWithTimeout(uint16_t baseAddress,
673  uint32_t timeout);
674 
675 //*****************************************************************************
676 //
687 //
688 //*****************************************************************************
689 extern void USCI_B_I2C_masterReceiveMultiByteStart(uint16_t baseAddress);
690 
691 //*****************************************************************************
692 //
701 //
702 //*****************************************************************************
703 extern uint8_t USCI_B_I2C_masterReceiveMultiByteNext(uint16_t baseAddress);
704 
705 //*****************************************************************************
706 //
718 //
719 //*****************************************************************************
720 extern uint8_t USCI_B_I2C_masterReceiveMultiByteFinish(uint16_t baseAddress);
721 
722 //*****************************************************************************
723 //
738 //
739 //*****************************************************************************
740 extern bool USCI_B_I2C_masterReceiveMultiByteFinishWithTimeout(uint16_t baseAddress,
741  uint8_t *rxData,
742  uint32_t timeout);
743 
744 //*****************************************************************************
745 //
756 //
757 //*****************************************************************************
758 extern void USCI_B_I2C_masterReceiveMultiByteStop(uint16_t baseAddress);
759 
760 //*****************************************************************************
761 //
773 //
774 //*****************************************************************************
775 extern void USCI_B_I2C_masterReceiveSingleStart(uint16_t baseAddress);
776 
777 //*****************************************************************************
778 //
791 //
792 //*****************************************************************************
793 extern bool USCI_B_I2C_masterReceiveSingleStartWithTimeout(uint16_t baseAddress,
794  uint32_t timeout);
795 
796 //*****************************************************************************
797 //
806 //
807 //*****************************************************************************
808 extern uint8_t USCI_B_I2C_masterReceiveSingle(uint16_t baseAddress);
809 
810 //*****************************************************************************
811 //
820 //
821 //*****************************************************************************
822 extern uint32_t USCI_B_I2C_getReceiveBufferAddressForDMA(uint16_t baseAddress);
823 
824 //*****************************************************************************
825 //
834 //
835 //*****************************************************************************
836 extern uint32_t USCI_B_I2C_getTransmitBufferAddressForDMA(uint16_t baseAddress);
837 
838 //*****************************************************************************
839 //
840 // Mark the end of the C bindings section for C++ compilers.
841 //
842 //*****************************************************************************
843 #ifdef __cplusplus
844 }
845 #endif
846 
847 #endif
848 #endif // __MSP430WARE_USCI_B_I2C_H__
uint8_t transmitData
MPU_initThreeSegmentsParam param